package com.kanche.bigbaby.bean;

import org.json.*;

import java.io.Serializable;
import java.util.ArrayList;

public class Merchant implements Serializable {
	
    private String phone;
    private String userId;
    private Address address;
    private String id;
    private String name;
    private String updateAt;
    private ArrayList<Contacts> contacts;
    private String createAt;
    private String comment;
    private ExtraInfo extraInfo;
    private Assistance assistance;
    
    
	public Merchant () {
		
	}	
        
    public Merchant (JSONObject json) {
    
        this.phone = json.optString("phone");
        this.userId = json.optString("userId");
        this.address = new Address(json.optJSONObject("address"));
        this.id = json.optString("id");
        this.name = json.optString("name");
        this.updateAt = json.optString("updateAt");

        this.contacts = new ArrayList<Contacts>();
        JSONArray arrayContacts = json.optJSONArray("contacts");
        if (null != arrayContacts) {
            int contactsLength = arrayContacts.length();
            for (int i = 0; i < contactsLength; i++) {
                JSONObject item = arrayContacts.optJSONObject(i);
                if (null != item) {
                    this.contacts.add(new Contacts(item));
                }
            }
        }
        else {
            JSONObject item = json.optJSONObject("contacts");
            if (null != item) {
                this.contacts.add(new Contacts(item));
            }
        }

        this.createAt = json.optString("createAt");
        this.comment = json.optString("comment");
        this.extraInfo = new ExtraInfo(json.optJSONObject("extraInfo"));
        this.assistance = new Assistance(json.optJSONObject("assistance"));

    }
    
    public String getPhone() {
        return this.phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Address getAddress() {
        return this.address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUpdateAt() {
        return this.updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public ArrayList<Contacts> getContacts() {
        return this.contacts;
    }

    public void setContacts(ArrayList<Contacts> contacts) {
        this.contacts = contacts;
    }

    public String getCreateAt() {
        return this.createAt;
    }

    public void setCreateAt(String createAt) {
        this.createAt = createAt;
    }

    public String getComment() {
        return this.comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public ExtraInfo getExtraInfo() {
        return this.extraInfo;
    }

    public void setExtraInfo(ExtraInfo extraInfo) {
        this.extraInfo = extraInfo;
    }

    public Assistance getAssistance() {
        return this.assistance;
    }

    public void setAssistance(Assistance assistance) {
        this.assistance = assistance;
    }


    
}
